<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 300px;
            height: 80px;
            margin: 0 auto;
            
            background-color: #000;
        }
        input{
            margin-top: 30px;
            width: 40px;
            text-align: center;
            height: 20px;
            background-color: #fff;
        }
        span{
            color: #fff;
            margin-left: 5px;
        }
    </style>
</head>
<body>
    <div id="box">
        <input type="text" readonly="readonly" id=""><span>时</span>
        <input type="text" readonly="readonly" id=""><span>分</span>
        <input type="text" readonly="readonly" id=""><span>秒</span>

    </div>
</body>
<script>
    // window.onload = function(){
    //     var inp = document.getElementsByTagName("input")
    //     var myDate = new Date()
    //     setInterval(onload,1000)
    //     time()
    //     function time(){
    //         inp[0].value = myDate.getHours()
    //         inp[1].value = myDate.getMinutes()
    //         myDate.getSeconds() < 10 ? (inp[2].value = "0"+myDate.getSeconds()) : inp[2].value = myDate.getSeconds()
    //     }
    // }

    window.onload = function(){
        var inp = document.getElementsByTagName('input')
        setInterval(tiem,1000)
        function tiem() {
            var myDate =new Date()
            inp[0].value = myDate.getHours()
            inp[1].value = myDate.getMinutes()
            myDate.getSeconds() < 10 ? (inp[2].value = "0"+myDate.getSeconds()) : inp[2].value = myDate.getSeconds()
        }
    }
</script>
</html>